﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace DMS.Logic
{
    public class Document
    {
		DBStorage _storage = new DBStorage(1);
		const int _bufferSize = 1024 * 1024;

		#region Properties

		public int FolderId { get; internal set; }

		public DateTime CreationDate { get; internal set; }

		public bool IsCheckedOut { get; private set; }

		public int DocumentTypeID { get; set; }

		public int NumberOfDownloads { get; private set; }

		public int NumberOfRatings { get; private set; }

		public int TotalRatings { get; private set; }

		public string OriginalFileName { get; internal set; }

		public string Name { get; set; }

		#endregion

		public void Save()
        {
            
        }

        internal void Write(Stream input)
        {
			BinaryReader reader = new BinaryReader(input);

			byte[] buffer = new byte[_bufferSize];

			int red = 0;
			while (red>0)
			{
				red = reader.Read(buffer, 0, _bufferSize);
				_storage.Write(buffer);
			}
        }

        public void Dispose()
        {

        }
    }
}
